<?php 

require_once '../mysqlConnect.php';

if (isset($_POST)) {
	
	$id = $_POST['id'];
	$dosage = $_POST['dosage'];
	$startdate = $_POST['startdate'];
	$enddate = $_POST['enddate'];
	
	if ($dosage == "" || $dosage == null)
		$returnValue = 'missing';
	if ($startdate == "" || $startdate == null)
		$returnValue = 'missing';
	if ($enddate == "" || $enddate == null)
		$returnValue = 'missing';	
	
	
	$sql = "UPDATE prescription_records SET dosage = '" . $dosage . "', start_date = '" . $startdate . "', end_date = '" . $enddate . "' WHERE id = '" . $id . "' LIMIT 1";
	
	$conn = GetConnection();
	$conn->query($sql);
	if ($conn->connect_errno)
		$returnValue = 'error';
	elseif ($conn->error)
		$returnValue = 'error';
	else
		$returnValue = 'success';
	
	echo $returnValue;
}